= $from && $now < $until) $correct[$path] = $pass; } } } } // bail if there is no current music if(empty($correct)) { header('Content-type: text/plain; charset=utf-8'); echo 'Most épp nincs semmilyen zene, gyere vissza később!'; exit; } // check for mp3 request $reqCnt = false; $reqName = false; if(preg_match('#^/get/(\d+)/([^/]+\.mp3)$#', $_SERVER['PATH_INFO'], $m)) { $reqCnt = (int) $m[1]; $reqName = urldecode($m[2]); if(strstr($reqName, '/')) { $reqName = false; $reqCnt = false; } } // check in files $found = false; $cntr = 0; foreach($correct as $path => $pass) { if($reqName) { // test if we have the file to dl $fp = $path . '/' . $reqName; if($reqCnt == $cntr && file_exists($fp)) { // demand authorization if(!isset($_SERVER['PHP_AUTH_USER']) || $pass != $_SERVER['PHP_AUTH_PW']) { header('WWW-Authenticate: Basic realm="djmary"'); header('HTTP/1.0 401 Unauthorized'); header('Content-type: text/plain; charset=utf-8'); echo 'Jelszót megmondtam az órán; a felhasználónév mindegy'; exit; } header('Content-type: application/octet-stream'); header('Content-length: ' . filesize($fp)); readfile($fp); exit; } } else { // list contents if(!$found) { echo 'Letölthető zenék'; echo ''; echo ''; echo '

Letölthető zenék

'; echo ''; echo ''; } if($reqName) { header('Content-type: text/plain; charset=utf-8'); echo 'Ilyen zene nincs!'; } ?>